﻿using Comm.Model;
using Comm.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Comm.Web.Action
{
    /// <summary>
    /// UsersManager 的摘要说明
    /// </summary>
    public class UsersManager :BaseHander
    {
        BLL.UsersService blluser = new BLL.UsersService();
        BLL.UserTypeInfoService blluserinfo = new BLL.UserTypeInfoService();
        protected string strData = string.Empty;
        public override void SonLoad()
        {
            string type = context.Request.Params["type"];
            switch (type) {
                case "usermanager":
                    DoDel();
                    break;
                case "change":
                    getChange();
                    break;
            }
       }


        public void DoDel() 
        {
            string userid = Request.Form["userId"];
            string carstute =Request.Form["tdscar"];
            string orderstatu =Request.Form["tdsorder"];
            //if (carsyatu == "false") 
            //{
            //    //说明没有参加购物  也就没有订单  直接删除

            //}
            int count = blluser.DelUpdate(int.Parse(userid),carstute,orderstatu);
            if (count > 0)
            {
                strData = "true";
            }
            else {
                strData = "false";
            }
            AjaxMsgHelper.AjaxMsg("ok", "删除成功~~~",JsonHelper.Serialize(strData));
        }

        public void getChange() 
        {
            int userid =int.Parse(Request.Form["userId"]);
            int typeid = int.Parse(Request.Form["typeid"]);
            int authorityId =int.Parse(Request.Form["value"]);
            UserTypeInfo model = new UserTypeInfo() 
            {
                 Id =typeid,
                 authorityId = authorityId,
                 userId = userid
            };
            blluserinfo.Update(model);
            AjaxMsgHelper.AjaxMsg("ok","修改成功！~");
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}